/*
 * Miya.com Inc.
 * Copyright (c) 2004-2018 All Rights Reserved.
 */
package com.miya.erpmofa.common.lang.enums;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang.StringUtils;

/**
 * 商品管理类别枚举类
 *
 * @author zhaowei
 * @version $Id: CommodityManageTypeEnum.java, v 0.1 2018年01月02日 20:26 PM
 */
@SuppressWarnings("unused")
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public enum CommodityManageTypeEnum {

    SELF_PRODUCT("SELF_PRODUCT", "SELF_PRODUCT", "自营单品", "自营单品"),

    SELF_CLASS("SELF_CLASS", "SELF_CLASS", "自营类品", "自营类品"),

    COUNTER_PRODUCT("COUNTER_PRODUCT", "COUNTER_PRODUCT", "专柜单品", "专柜单品"),

    COUNTER_CLASS("COUNTER_CLASS", "COUNTER_CLASS", "专柜类品", "专柜类品"),

    RENT_PRODUCT("RENT_PRODUCT", "RENT_PRODUCT", "租赁单品", "租赁单品"),

    RENT_CLASS("RENT_CLASS", "RENT_CLASS", "租赁类品", "租赁类品"),;
    /**
     * 枚举编码
     */
    @Getter
    private final String code;

    /**
     * 英文名
     */
    @Getter
    private final String englishName;

    /**
     * 中文名
     */
    @Getter
    private final String chineseName;

    /**
     * 枚举描述信息
     */
    @Getter
    private final String description;

    /**
     * 根据编码查询枚举。
     *
     * @param code 编码。
     * @return 枚举。
     */
    public static CommodityManageTypeEnum getByCode(String code) {
        for (CommodityManageTypeEnum value : CommodityManageTypeEnum.values()) {
            if (StringUtils.equals(code, value.getCode())) {
                return value;
            }
        }
        return null;
    }
}
